<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #canvas {
        border: 1px solid;
      }
    </style>
  </head>

  <body>
    <canvas width="400" height="400" id="canvas"> 请升级你的服务器 </canvas>
    <script>
      var canvas = document.querySelector("#canvas");
      var context = canvas.getContext("2d");
      context.font = "50px sans-serif";
      context.textAlign = "center";
      // context.strokeText(text, x, y, maxWidth);
        context.shadowOffsetX=0;
        context.shadowOffsetY=20;
        context.shadowColor='blue';
        context.shadowBlur=10;
        context.strokeText("绘制阴影", 200, 200);
        var speedX = 0.2,speedY = -0.2;
        setInterval(() => {
            context.clearRect(0,0,400,400);
            context.shadowOffsetX += speedX;
            context.shadowOffsetY += speedY;
            if (context.shadowOffsetX > 20 ) {
                speedX = speedX*-1
            } else if (context.shadowOffsetX < -20 ) {
                speedX = speedX*-1
            }
            if (context.shadowOffsetY > 20 ) {
                speedY = speedY*-1
            } else if (context.shadowOffsetY < -20 ) {
                speedY = speedY*-1
            }
            // if (context.shadowOffsetY > 20 ) {
            //     context.shadowOffsetY - speed;
            // } else if (context.shadowOffsetY < -20 ) {
            //     context.shadowOffsetX += speed;
            // }
            context.strokeText("绘制阴影", 200, 200);
        }, 16.7);
        
        
    
    </script>
  </body>
</html>
